using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using LocalizationTest.Tools;

namespace LocalizationTest
{
  public class WorldState1D : WorldState
  {
    private double position;

    public double Position
    {
      get { return position; }
      set { position = value; }
    }

    public override void Move(WorldState relativeState)
    {
      position += ((WorldState1D)relativeState).position;
    }

    public override void Kidnap()
    {
      position = Globals.stateSpaceInitialX;
    }

    
    public WorldState1D() 
    {
      position = 0;
    }

    public WorldState1D(double _position)
    {
      position = _position;
    }

    public override object Clone()
    {
      return this.MemberwiseClone();
    }

    public override void DrawShaded(double shade, Color color, string drawingID)
    {
      Color color2 = DrawingTools.GetShadedColor(shade, ref color);
      DebugDrawingTool.CreateCircle(drawingID, new Vector2(position, 0), Globals.rasterWidth / 5, Globals.rasterWidth / 5, color2);
    }

    public override void Draw(double probability, string drawingID)
    {
      DebugDrawingTool.CreateLine(drawingID, new Vector2(position, 0), new Vector2(position, 1500 * probability), Globals.rasterWidth, Color.Gray);
    }
    public override void DrawWithIntensity(int intensity, string drawingID, double rasterWidth)
    {
      Color color = Color.FromArgb(64, 128, 128, 128);
      DebugDrawingTool.CreateLine(drawingID, new Vector2(position, 0), new Vector2(position, intensity * 2), rasterWidth, color);
    }
    public override void DrawHighlighted(string drawingID, Color color)
    {
      DebugDrawingTool.CreateLine(drawingID, new Vector2(position, 0), new Vector2(position, -25), 10, color);
      //      DebugDrawingTool.CreateCircle(drawingID,
//        new Vector2(position, 0), 30, 5, color);
    }

    public override void DrawConnectingLine(WorldState otherWorldstate, string drawingID, Color color)
    {
      DebugDrawingTool.CreateLine(drawingID,
        new Vector2(position, 0),
        new Vector2((otherWorldstate as WorldState1D).position, 0), 3, color);
    }

    public override List<FunctionWorldState>  CreateListOfWorldStates(WorldState minimum, WorldState maximum, WorldState step)
    {
      List<FunctionWorldState> function = new List<FunctionWorldState>();
      double min = (minimum as WorldState1D).Position;
      double max = (maximum as WorldState1D).Position;
      double stepLength = (step as WorldState1D).Position;
      for (double x = min; x <= max; x += stepLength)
      {
        function.Add(new FunctionWorldState(new WorldState1D(x), 10));
      }
      return function;
    }

    public override string ToString()
    {
      throw new Exception("The method or operation is not implemented.");
    }

    public override WorldState Parse(string str)
    {
      throw new Exception("The method or operation is not implemented.");
    }

    public override double[] ToDoubleArray()
    {
      double[] toReturn = new double[1];
      toReturn[0] = position;
      return toReturn;
    }

    public override void FromDoubleArray(double[] doubleArray)
    {
      position = doubleArray[0];
    }
  }
}